package top.sdaily.web.controller.sys;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.sdaily.web.context.ReturnBody;
import top.sdaily.web.model.Right;
import top.sdaily.web.service.RightService;

/**
 * Created by soya on 2017/1/23.
 */
@RestController
@RequestMapping("right")
public class RightController {

    @Autowired
    RightService rightService;

    @GetMapping
    public ReturnBody getAll(){
        return ReturnBody.success().setData(rightService.getAll());
    }

    @PostMapping
    public ReturnBody create(@RequestBody Right right){
        rightService.create(right);
        return ReturnBody.success().setData(right);
    }

    @PutMapping
    public ReturnBody modify(@RequestBody Right right){
        rightService.modify(right);
        return ReturnBody.success().setData(right);
    }

    @DeleteMapping("/{pkid}")
    public ReturnBody del(@PathVariable String pkid){
        rightService.delete(pkid);
        return ReturnBody.success();
    }
}
